package com.jlu155.CourseManager.repository;

import java.util.List;

import com.jlu155.CourseManager.entity.Session;
import org.apache.ibatis.annotations.*;

public interface SessionRepository {

    // 插入课程会话信息
    @Insert("insert into session(tc_id, start_time, end_time, weekday,classroom) values (#{tc_id}, #{start_time}, #{end_time}, #{weekday}, #{classroom})")
    @Options(useGeneratedKeys = true, keyProperty = "session_id")
    public int insertSession(Session session);

    // 按会话ID查询课程会话信息
    @Select("select * from session where session_id=#{session_id}")
    Session findSessionById(Integer session_id);

    // 按教师课程ID查询课程会话信息
    @Select("select * from session where tc_id=#{tc_id}")
    List<Session> findSessionsByTcId(Integer tc_id);

    // 删除课程会话信息
    @Delete("delete from session where session_id=#{session_id}")
    public boolean deleteSession(Integer session_id);

    // 查询所有课程会话信息
    @Select("select * from session")
    public List<Session> findAllSessions();

    // 更新课程会话信息
    @Update("update session set tc_id=#{tc_id}, start_time=#{start_time}, end_time=#{end_time}, weekday=#{weekday},  classroom=#{classroom} where session_id=#{session_id}")
    public boolean updateSession(Session session);
}
